//
//  HDCustomView.m
//  AccountEasy
//
//  Created by mac on 2020/7/31.
//  Copyright © 2020 AccountEasy. All rights reserved.
//

#import "HDCustomView.h"

@interface HDCustomView()

@end


@implementation HDCustomView

+(instancetype)initWithPoint:(CGPoint) point {
    HDCustomView *view = [[HDCustomView alloc] initWithFrame:SARectMake(point.x, point.y, 375, 40)];
    view.backgroundColor = [UIColor whiteColor];
    UILabel *leftLab = [[UILabel alloc] initWithFrame:SARectMake(38, 0, 100, 40)];
    leftLab.textAlignment = NSTextAlignmentLeft;
    leftLab.textColor = kGrayColor;
    leftLab.font = kFont(14);
    [view addSubview:leftLab];
    view.leftLab = leftLab;
    
    UILabel *rightLab = [[UILabel alloc] initWithFrame:SARectMake(157, 0, 180, 40)];
    rightLab.textAlignment = NSTextAlignmentRight;
    rightLab.textColor = kGrayColor;
    rightLab.font = kFont(14);
    [view addSubview:rightLab];
    view.rightLab = rightLab;
    
    UIButton *iconBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [iconBtn setImage:[UIImage imageNamed:@"icon_question"] forState:UIControlStateNormal];
    iconBtn.frame = SARectMake(100, 0, 40, 40);
    iconBtn.hidden = YES;
    [view addSubview:iconBtn];
    view.iconBtn = iconBtn;
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:view action:@selector(clickedTap)];
    [view addGestureRecognizer:tap];
    
    return view;
}

+(instancetype)initAllowWithPoint:(CGPoint) point {
    HDCustomView *view = [[HDCustomView alloc] initWithFrame:SARectMake(point.x, point.y, 375, 40)];
    view.backgroundColor = [UIColor whiteColor];
    UILabel *leftLab = [[UILabel alloc] initWithFrame:SARectMake(38, 0, 100, 40)];
    leftLab.textAlignment = NSTextAlignmentLeft;
    leftLab.textColor = kGrayColor;
    leftLab.font = kFont(14);
    [view addSubview:leftLab];
    view.leftLab = leftLab;
    
    UILabel *rightLab = [[UILabel alloc] initWithFrame:SARectMake(157, 0, 160, 40)];
    rightLab.textAlignment = NSTextAlignmentRight;
    rightLab.textColor = kGrayColor;
    rightLab.font = kFont(14);
    [view addSubview:rightLab];
    view.rightLab = rightLab;
    
    UIImageView *allowImageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"noCard_rightAllow"]];
    allowImageV.frame = SARectMake(322, 13, 15, 15);
    [view addSubview:allowImageV];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:view action:@selector(clickedTap)];
    [view addGestureRecognizer:tap];
    
    return view;
}

#pragma mark - event
-(void)clickedTap {
    !self.tapBlock ?: self.tapBlock();
}

@end
